﻿<Controls:SinacorWindow
    
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"    
    xmlns:Controls="clr-namespace:Sinacor.Infra.UI.Controls.SmartClient;assembly=Sinacor.Infra.UI.Controls"
    xmlns:Validation="clr-namespace:Sinacor.Infra.UI.Controls.SmartClient.Validation;assembly=Sinacor.Infra.UI.Controls"
    xmlns:Edit="clr-namespace:Sinacor.Infra.UI.Controls.SmartClient.Edit;assembly=Sinacor.Infra.UI.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"    
    mc:Ignorable="d"    
    WindowStartupLocation="CenterScreen" 
    AutoContentHeight="False" 
    AutoContentWidth="True"
    WindowState="Maximized" 
    Title="{DynamicResource Bovespa.Ordens.Label.Titulo.AjusteMercadoFuturo}"   
    x:Class="Sinacor.UI.Bovespa.Ordens.View.SmartClient.AjusteMercadoFuturo"
    ModulePlus="False"
    ModuleId="ORD" 
    
    >
    <Controls:SinacorExpanderContainer Name="expanderContainerPai">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Filtro da Pesquisa -->
        <Controls:SinacorExpander x:Name="expanderPesquisa" Grid.Row="0" Header="{DynamicResource Bovespa.Ordens.Label.Pesquisa}" IsExpanded="True">
            <Grid Validation:ValidationManager.ValidationGroup="PesquisaAtivo">
                <Controls:SinacorLabel x:Name="lblPregao" 
                                       Content="{DynamicResource Bovespa.Ordens.Label.Pregao}" 
                                       HorizontalAlignment="Left" 
                                       Margin="0,0,0,0" 
                                       VerticalAlignment="Top" 
                                       Width="110" 
                                       HorizontalContentAlignment="Right" 
                                       IsTargetFieldRequired="True"/>

                <Controls:SinacorComboBox x:Name="cmbFiltroDataPregao"                                          
                                          SelectedValue="{Binding Filtro.DataPregao}"
                                          ItemsSource="{Binding CalendarioPregao}" 
                                          SelectedValuePath="DataPregaoShortDateString"
                                          DisplayMemberPath="DataPregaoShortDateString"
                                          HorizontalAlignment="Left" 
                                          VerticalAlignment="Top" 
                                          Margin="114,0,0,0" 
                                          Width="100" 
                                          IsRequired="True" 
                                          CausesValidation="True"                                                                  
                                          RequiredErrorMessage="Bovespa.Ordens.Message.DataPregaoObrigatorio" TabIndex="1"/>

                <Controls:SinacorLabel x:Name="lblAtivo" 
                                       Content="{DynamicResource Bovespa.Ordens.Label.Ativo}" 
                                       Margin="218,0,0,0" 
                                       Width="65" 
                                       HorizontalAlignment="Left" 
                                       VerticalAlignment="Top" 
                                       HorizontalContentAlignment="Right" />

                <Controls:SinacorTextBox x:Name="txtAtivo" 
                                         HorizontalAlignment="Left" 
                                         Width="100" 
                                         Margin="287,0,0,0" 
                                         VerticalAlignment="Top"
                                         CharacterCasing="Upper"
                                         MaxLength="12" 
                                         Text="{Binding Filtro.CodigoNegociacao}"  
                                         PreviewLostKeyboardFocus="txtAtivo_PreviewLostKeyboardFocus" TabIndex="2" />

                <Controls:SinacorButton x:Name="btnPesquisarAtivo" 
                                        Click="btnPesquisarAtivo_Click" 
                                        HorizontalAlignment="Left" 
                                        VerticalAlignment="Top" 
                                        Margin="391,0,0,0" 
                                        CausesValidation="True"
                                        ClearServiceErrors="True" 
                                        Validation:ValidationManager.ValidationGroup="PesquisaAtivo"
                                        TabIndex="3"
                                        Icon="IconButtonSearch"
                                        ToolTip="{DynamicResource Bovespa.Ordens.Tooltip.PesquisarAtivo}"/>

                <Controls:SinacorButton x:Name="btnPesquisar"
                                        Click="btnPesquisar_Click"  
                                        Content="{DynamicResource Bovespa.Ordens.Label.Pesquisar}" 
                                        Margin="418,0,0,0" 
                                        Width="100" 
                                        HorizontalAlignment="Left" 
                                        VerticalAlignment="Top" 
                                        IsDefault="True"
                                        CausesValidation="True"
                                        ClearServiceErrors="True" 
                                        Validation:ValidationManager.ValidationGroup="PesquisaAtivo" TabIndex="4" />
                <Controls:SinacorButton x:Name="btnNovaPesquisa"
                                        Click="btnNovaPesquisa_Click"  
                                        Content="{DynamicResource Bovespa.Ordens.Label.NovaPesquisa}" 
                                        Margin="522,0,0,0" 
                                        Width="106" 
                                        HorizontalAlignment="Left" 
                                        VerticalAlignment="Top" 
                                        ClearServiceErrors="True" />
            </Grid>
        </Controls:SinacorExpander>
        <!-- Fim Filtro da Pesquisa -->

        <Controls:SinacorExpander x:Name="expanderNegocio" Header="{DynamicResource Bovespa.Ordens.Label.TituloExpNegocio}" Grid.Row="1" IsExpanded="True" Margin="0,4,0,0" AllowExpand="False">
            <Grid>

                <Controls:SinacorDataGrid HorizontalAlignment="Stretch" 
                                          VerticalAlignment="Stretch"                                          
                                          Name="dtgAjusteMercadoFuturo"                                           
                                          ItemsSource="{Binding Path=ajusteMercadoFuturoPresenter.ListaAjusteMercadoFuturo, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:SinacorWindow}}}"                                          
                                          SavingAll="dtgAjusteMercadoFuturo_SavingAll"                                          
                                          InsertBegun="dtgAjusteMercadoFuturo_InsertBegun"
                                          UpdateBegun="dtgAjusteMercadoFuturo_UpdateBegun"
                                          UndoingAll="dtgAjusteMercadoFuturo_UndoingAll"
                                          IsSynchronizedWithCurrentItem="True"
                                          AllowDelete="True"                                           
                                          AllowSave="False"                                          
                                          AllowSaveAll="True">

                    <!-- ContextMenu -->
                    <Controls:SinacorDataGrid.ContextMenuTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <Controls:SinacorContextMenuItem Header="{DynamicResource Bovespa.Ordens.Label.AjustarPosicao}" Name="menuItemAjustarPosicao" Click="AjustarPosicao_Click"/>
                            </StackPanel>
                        </DataTemplate>
                    </Controls:SinacorDataGrid.ContextMenuTemplate>
                    <!-- Fim ContextMenu -->

                    <Controls:SinacorDataGrid.Columns>

                        <!-- Data do Pregao -->
                        <Controls:Column Title="Bovespa.Ordens.Label.Data" 
                                         DisplayMemberPath="DataPregao"
                                         Name="colDataPregao"
                                         AllowUpdate="False" 
                                         AllowInsert="True"  
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}"  
                                         AutoAdjustWidthToContent="False"
										 Width="110"										
                                         HorizontalCellAlignment="Center" >
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>

                                    <Controls:SinacorComboBox Name="cmbDataPregao"                                                                
                                                              SelectedValue="{Binding DataPregao}"
                                                              ItemsSource="{Binding Path=ajusteMercadoFuturoPresenter.CalendarioPregao, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:SinacorWindow}}}" 
                                                              SelectedValuePath="DataPregaoShortDateString"
                                                              DisplayMemberPath="DataPregaoShortDateString"                                                                
                                                              IsRequired="True"
                                                              RequiredErrorMessage="Bovespa.Ordens.Message.InformeDataPregao"
                                                              Width="100" />

                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <!-- Codigo Negociacao -->
                        <Controls:Column Title="Bovespa.Ordens.Label.Ativo" 
                                         Name="colCodigoNegociacao"
                                         DisplayMemberPath="CodigoNegociacao"
                                         AllowUpdate="False" 
                                         AllowInsert="True"
                                         AutoAdjustWidthToContent="False"
										 Width="107"
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}"                                         
                                         HorizontalCellAlignment="Right">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorTextBox Name="textCodigoNegociacao" 
                                                             Text="{Binding CodigoNegociacao}"
                                                             MaxLength="12" 
                                                             ToolTip="{DynamicResource Bovespa.Ordens.Tooltip.IdentificacaoAtivo}"                                                              
                                                             PreviewLostKeyboardFocus="textCodigoNegociacao_PreviewLostKeyboardFocus"
                                                             Width="100"                                                              
                                                             CharacterCasing="Upper"                                                             
                                                             HorizontalContentAlignment="Right"                                                               
                                                             IsRequired="True" 
                                                             RequiredErrorMessage="Bovespa.Ordens.Message.InformeAtivo"/>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <!-- Preco do Exercicio -->
                        <Controls:Column Title="Bovespa.Ordens.Label.Exercicio"   
                                         DisplayMemberPath="PrecoExercicio"
                                         Name="colPrecoExercicio"                                         
                                         AllowUpdate="True"    
                                         AllowInsert="True"
                                         AutoAdjustWidthToContent="False"
										 Width="107"
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}"                                          
                                         Integers="11"
                                         Decimals="2"
                                         StringFormat="n2"
                                         HorizontalCellAlignment="Right">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDecimalTextBox Name="txtPrecoExercicio" 
                                                                    Value="{Binding PrecoExercicio}"                                                                     
                                                                    Decimals="2" 
                                                                    Integers="11"
                                                                    IsEnabled="False"
                                                                    ToolTip="{DynamicResource Bovespa.Ordens.Label.Exercicio}"                                                                     
                                                                    Width="100" 
                                                                    HorizontalContentAlignment="Right"/>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <!-- Fator de Cotacao -->
                        <Controls:Column Title="Bovespa.Ordens.Label.Fator" 
                                         DisplayMemberPath="Fator"
                                         Name="colFator"                                         
                                         AllowInsert="True"
                                         AllowUpdate="True"
                                         AutoAdjustWidthToContent="False"
										 Width="107"
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}"                                          
                                         HorizontalCellAlignment="Right"
                                         Integers="7">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDecimalTextBox Name="txtFatorCotacao" 
                                                                    Value="{Binding Fator}"
                                                                    MaxLength="7"                                                                     
                                                                    Integers="7"
                                                                    IsEnabled="False"
                                                                    ToolTip="{DynamicResource Bovespa.Ordens.Tooltip.FatorCotacao}"                                                                     
                                                                    Width="100" 
                                                                    HorizontalContentAlignment="Right"/>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <!-- Valor Ajuste Anterior -->
                        <Controls:Column Title="Bovespa.Ordens.Label.AjusteD1"   
                                         DisplayMemberPath="ValorAjusteAnterior"
                                         Name="colValorAjusteAnterior"
                                         AllowUpdate="True" 
                                         AllowInsert="True"
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}"                                          
                                         HorizontalCellAlignment="Right"
                                         Decimals="7" 
                                         Integers="11"                                          
                                         StringFormat="f7"
                                         AutoAdjustWidthToContent="False"
										 Width="126" >
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDecimalTextBox Name="textValorAjusteAnterior" 
                                                                    Value="{Binding ValorAjusteAnterior}"                                                                     
                                                                    Decimals="7" 
                                                                    Integers="11"                                                                    
                                                                    ToolTip="{DynamicResource Bovespa.Ordens.Tooltip.ValorAnteriorAjuste}"                                                                     
                                                                    PreviewLostKeyboardFocus="textValorAjusteAnterior_PreviewLostKeyboardFocus"
                                                                    Width="120" 
                                                                    HorizontalContentAlignment="Right"                                                                     
                                                                    IsRequired="True" 
                                                                    RequiredErrorMessage="Bovespa.Ordens.Message.InformeValorAjusteAnterior"
                                                                    IsFormated="False" />
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <!-- Valor Ajuste Atual -->
                        <Controls:Column Title="Bovespa.Ordens.Label.AjusteD0"  
                                         DisplayMemberPath="ValorAjusteAtual"
                                         Name="colValorAjusteAtual"
                                         AllowUpdate="True" 
                                         AllowInsert="True"
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}"
                                         AutoAdjustWidthToContent="False"
										 Width="106"
                                         HorizontalCellAlignment="Right"
                                         Decimals="7" 
                                         Integers="11"
                                         StringFormat="f7">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDecimalTextBox Name="textValorAjusteAtual" 
                                                                    Value="{Binding ValorAjusteAtual}"                                                                    
                                                                    Decimals="7" 
                                                                    Integers="11"                                                                    
                                                                    ToolTip="{DynamicResource Bovespa.Ordens.Tooltip.ValorAtual}"                                                                     
                                                                    PreviewLostKeyboardFocus="textValorAjusteAtual_PreviewLostKeyboardFocus"
                                                                    Width="100" 
                                                                    HorizontalContentAlignment="Right"                                                                    
                                                                    IsRequired="True"                                                                    
                                                                    RequiredErrorMessage="Bovespa.Ordens.Message.InformeValorAjusteAtual" 
                                                                    IsFormated="False"/>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <!-- Valor Ajuste Aplicado -->
                        <Controls:Column Title="Bovespa.Ordens.Label.AjusteD0D1"    
                                         DisplayMemberPath="AjusteAplicado"
                                         Name="colAjusteAplicado"
                                         AllowUpdate="True" 
                                         AllowInsert="True"
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}"
                                         AutoAdjustWidthToContent="False"
										 Width="157" 
                                         Integers="11" 
                                         Decimals="7"
                                         HorizontalCellAlignment="Right"
                                         StringFormat="f7">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDecimalTextBox Name="textValorAjusteAplicado" 
                                                                    Value="{Binding AjusteAplicado}"                                                                    
                                                                    Integers="11" 
                                                                    Decimals="7"
                                                                    ToolTip="{DynamicResource Bovespa.Ordens.Tooltip.AjusteAplicado}"                                                                     
                                                                    Width="150"
                                                                    AcceptsNegative="True"
                                                                    HorizontalContentAlignment="Right"                                                                     
                                                                    IsEnabled="False"
                                                                    IsFormated="False"/>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <!-- Variacao -->
                        <Controls:Column Title="Bovespa.Ordens.Label.Variacao"  
                                         DisplayMemberPath="Variacao"
                                         Name="colVariacao"
                                         AllowUpdate="True" 
                                         AllowInsert="True"                                         
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}"
                                         AutoAdjustWidthToContent="False"
										 Width="106" 
                                         Integers="11" 
                                         Decimals="7"
                                         StringFormat="f5"
                                         HorizontalCellAlignment="Right">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDecimalTextBox Name="textVariacao" 
                                                                    Value="{Binding Variacao}"                                                                    
                                                                    Integers="11" 
                                                                    Decimals="7"
                                                                    ToolTip="{DynamicResource Bovespa.Ordens.Label.Variacao}" 
                                                                    IsEnabled="False"
                                                                    Width="100"
                                                                    AcceptsNegative="True" 
                                                                    HorizontalContentAlignment="Right" 
                                                                    IsFormated="True" />
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                    </Controls:SinacorDataGrid.Columns>

                </Controls:SinacorDataGrid>

            </Grid>
        </Controls:SinacorExpander>

    </Controls:SinacorExpanderContainer>

</Controls:SinacorWindow>
